<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        // 可以忽略js的执行顺序
        //方法一
        window.onload = function() {
            var d = document.getElementsByTagName('div');
            console.log(d);
        }

        //方法二
        window.addEventListener('load', function() {
            var d = document.getElementsByTagName('div');
            console.log(d);
        })
    </script>


    <div></div>


</body>

</html>